<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style type="text/css">
    
    .tab ul {
      overflow: hidden;
      padding: 0;
      margin: 0;
    }
    .tab ul li {
      box-sizing: border-box;
      padding: 0;
      float: left;
      width: 100px;
      height: 45px;
      line-height: 45px;
      list-style: none;
      text-align: center;
      border-top: 1px solid rgb(208, 255, 0);
      border-right: 1px solid rgb(255, 209, 3);
    }
    .tab ul li:first-child {
      border-left: 1px solid rgb(27, 208, 193);
    }
    .tab ul li.active {
      background-color: rgb(162, 145, 182);
    }
    .tab div {
      width: 500px;
      height: 300px;
      display: none;
      text-align: center;
      font-size: 30px;
      line-height: 300px;
      border: 1px solid rgb(90, 201, 80);
      border-top: 0px;
    }
    .tab div.current {
      display: block;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="tab">
      <ul>
        <li :class='{active:item.id==ID}' :key='item.id' v-for='(item,index) in list' @click=cli(item.id)>{{item.title}}</li>
      </ul>
      <div :class='{current:item.id==ID}' :key='item.id' v-for='(item, index) in list'>
        <img :src="item.path" v-if="">
      </div>
    </div>
  </div>
  <script type="text/javascript" src="vue.js"></script>
  <script type="text/javascript">
    // 要求: 增加数据, 控制li的选中状态, 以及div的显示状态
    var vm = new Vue({
      el: '#app',
      data: {
        ID:"1",
        list: [{
          id: 1,
          title: 'apple',
          path: 'img/apple.png'
        },{
          id: 2,
          title: 'orange',
          path: 'img/orange.png'
        },{
          id: 3,
          title: 'lemon',
          path: 'img/lemon.png'
        }]
      },
      methods: {
        cli(id){
          this.ID=id
        }
      }
    });
  </script>
</body>
</html>
